package com.example.carefree_server.service.impl.i_studentImpl;

import com.example.carefree_server.entity.Activity;
import com.example.carefree_server.mapper.m_studentMapper.ActivityMapper;
import com.example.carefree_server.service.s_studentService.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {
    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public List<Activity> findActivityById(String sid) {
        return activityMapper.findActivityById(sid);
    }

    @Override
    public List<Activity> findActivitiesByType(String sid, String type) {
        List<Activity> list = new ArrayList<>();
        if ("创造能力".equals(type) || "文体能力".equals(type) || "社会实践能力".equals(type)) {
            list = activityMapper.findActivitiesByType(sid, type);
        } else {
           return null;
        }
        return list;
    }

    @Override
    public List<Activity> findActivitiesByTypes(String sid, String type, String types) {
        List<Activity> list = new ArrayList<>();
        if ("创造能力".equals(type)) {
            if ("学科竞赛".equals(types)||"参加校科研项目".equals(types)||"报刊投稿录用".equals(types)||"其他项".equals(types)) {
                list = activityMapper.findActivitiesByTypes(sid, type ,types);
            }else{
                list = activityMapper.findActivitiesByType(sid, type);
            }
        } else if("文体能力".equals(type)){
            if ("体育竞赛".equals(types)||"文艺竞赛".equals(types)||"参加校内外各种艺术比赛".equals(types)||"其它项".equals(types)) {
                list = activityMapper.findActivitiesByTypes(sid, type ,types);
            }else{
                list = activityMapper.findActivitiesByType(sid, type);
            }
        } else if("社会实践能力".equals(type)){
            if ("公益事业".equals(types)||"参加三下乡".equals(types)||"参加校系组织的讲座".equals(types)||"网络平台参与比赛".equals(types)||"其他项".equals(types)) {
                list = activityMapper.findActivitiesByTypes(sid, type ,types);
            }else{
                list = activityMapper.findActivitiesByType(sid, type);
            }
        }
        return list;
    }

    @Override
    public List<Activity> findAllActivity() {
        return activityMapper.findAllActivity();
    }
}
